﻿
using System;
using System.Windows;
using System.Windows.Data;
using Coding4Fun.Toolkit.Controls;
using eLearning.Model;

namespace eLearning.Util
{
    public class MessageTypeConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (((Post)value).Side == PostSide.Me)
            {
                if (parameter == null)
                    return 1;
                else if (parameter.ToString() == "background")
                {
                    return "DodgerBlue";
                }
                else
                {
                    if (parameter.ToString() == "direction") // return chat "triangle" direction
                    {
                        return ChatBubbleDirection.LowerRight;
                    }
                    else  // return aligment
                    {
                        return HorizontalAlignment.Right;
                    }
                }
            }
            else
            {
                if (parameter == null)
                    return .5;
                else if (parameter.ToString() == "background")
                {
                    return "#FFFFC600";
                }
                else
                {
                    if (parameter.ToString() == "direction")
                    {
                        return ChatBubbleDirection.UpperLeft;
                    }
                    else
                    {
                        return HorizontalAlignment.Left;
                    }
                }
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
